package edu.hubu.robots;

import edu.hubu.robots.man.entity;
import edu.hubu.robots.mp.mapper;
import edu.hubu.robots.sv.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class impl implements service {
    @Autowired
    private mapper mapper0;
    public vo addRobot(entity entity){
        int i = mapper0.addRobot(entity);

        if (i > 0) {
            return new vo(200, "添加成功！", null);
        } else {
            return new vo(500, "添加失败！", null);
        }
    }
    public vo updateRobot(int id,String xinghao,int number,String remark){
        int i = mapper0.updateRobot(id,xinghao,number,remark);

        if (i > 0) {
            return new vo(200, "更新成功！", null);
        } else {
            return new vo(500, "更新失败！", null);
        }
    }
    public vo removeRobot(int id){
        int i = mapper0.removeRobot(id);
        if (i > 0) {
            return new vo(200, "删除成功！", null);
        } else {
            return new vo(500, "删除失败！", null);
        }
    }

    public vo selectRobot(String xinghao){
        List<entity> entities = mapper0.selectRobot(xinghao);
        if (entities != null) {
            return new vo(200, "查询到", entities);
        } else {
            return new vo(500, "没有", entities);
        }
    }


    public vo listRobot(){
        List<entity> entities = mapper0.listRobot();
        if (entities != null) {
            return new vo(200, "查询到", entities);
        } else {
            return new vo(500, "没有", entities);
        }
    }

}
